package com.kuang.demo01;

/**守护线程
 * @author FHL
 */
public class TestDaemon {
    public static void main(String[] args) {
God god=new God();
You you=new You();
        Thread thread = new Thread(god);

        thread.setDaemon(true);
        //默认值为false，正常的线程都是用户线程
        thread.start();
        //启动God线程(守护线程)
        new Thread(you).start();
    }

    static class God implements Runnable{
        @Override
        public void run() {
            //这个线程一直持续着，可以不设置关闭
            while (true){
                System.out.println("保佑你！");
            }
        }
    }
    static class You implements Runnable{
        @Override
        public void run() {
            for (int i = 0; i < 36600; i++) {
                System.out.println("day" +
                        "and day with happy");
            }
            System.out.println("game over!");

        }
    }
}
